package com.hc.sss.llz.controller;

import com.hc.sss.common.ResultMap;
import com.hc.sss.pojo.Dict;
import com.hc.sss.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("dict")
public class DictController {

    @Autowired
    DictService dictService;

    //根据基础数据类型查询
    @RequestMapping("/findDictByDictTypeList")
    @ResponseBody
    public List<Dict> findDictByDictTypeList(String dictType) {
        return dictService.findDictByDictTypeList(dictType);
    }

	//根据基础数据类型查询
	@RequestMapping("/findDictList")
	@ResponseBody
	public ResultMap<Dict> findDictList(Dict dict,Integer page,Integer limit) {
		Map<String, Object> paramMap = new HashMap<>();
		paramMap.put("page", page);
		paramMap.put("limit", limit);
		paramMap.put("dict", dict);
		ResultMap<Dict> resultMap = dictService.findDictList(paramMap);
		return resultMap;
	}
	
	//删除基本数据修改状态
	@RequestMapping("/deleteDict")
	@ResponseBody
	public int deleteDict(Dict dict) {
		dict.setDictStatus(-1);
		return dictService.updateDict(dict);
	}
	
	//修改基本数据
	@RequestMapping("/updateDict")
	@ResponseBody
	public int updateDict(Dict dict){
		return dictService.updateDict(dict);
	}
	
	//添加基础数据
	@RequestMapping("/insertDict")
	@ResponseBody
	public int insertDict(Dict dict){
		return dictService.insertDict(dict);
	}
	
	
	
	
	
	
	
}
